package com.atguigu.tingshu.demo.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * Author:huzhongkui
 * Date: 2025-01-17 星期五 15:03:03
 * Description:  实体类和es索引库的文档绑定
 */

@Document(indexName = "person")   // 索引库的名字person
@Data
public class Person {


    // 文档的id
    @Id
    private Long id;
    // 文档的name(java中的string在es中有两种类型 keyword和text)
    @Field(value = "name", type = FieldType.Text, index = true, analyzer = "ik_max_word")
    private String name;
    @Field(value = "address", type = FieldType.Keyword, index = false)
    private String address;

    @Field(value = "age", type = FieldType.Integer, index = true)
    private Integer age;
}